home *** CD-ROM | disk | FTP | other *** search
- Documentation for Version 3.00
- ==============================
-
- In the beginning Steve Marcus (CIS 72007,1233) posted a basic date
- manipulation/arithmetic class produced with Borland C++ 2.0 in the
- BPROGB forum, with a request for suggestions and enhancements. This was
- on 6/19/91.
-
- A rather enterprising gentleman by the name of Eric Simon (CIS 70540,1522)
- accepted the challenge, and produced a new and improved version in the
- course of a project he was developing at work. He contributed the results
- to the forum on 6/29/91, also inviting enhancements and comments.
-
- Coincidentally, I developed a need for a universal date conversion routine
- about the same time for use in a business project I was developing as well.
- Browsing the same forum, I encountered Eric's class, which provided much of
- the functionality I needed - the basic julian-gregorian and day of week
- conversion algorithms - relieving me of the task of researching or re-
- inventing them. He had also added overloaded + and - operators for
- incrementing date objects by integer days, as well as several print functions.
-
- I needed additional features for my implementations, so I set about adding
- to the class. As is my habit, I got carried away.
-
- The class now has:
-
- 1. A full set of constructors, allowing construction and re-setting
- of any date object from a julian date (the universal kind, relative
- to 1/1/4713 B.C.E., not the YYDDD kind); from a date string (i.e.
- 11/15/1991);from another date object (copy constructor); or from a
- "date" struct as defined in dos.h and returned by getdate(). A date
- object may also be set to the current system date by assigning it to
- the string "today" (case-insensitive).
-
- 2. A full set of comparison operators ( <, <=, >, >=, ==, !=),
- defined as friend functions so that date objects may be freely
- compared to other date objects, to julian dates, or to strings.
-
- 3. A full set of arithmetic operators ( +, -, ++, --, += and -=).
- Additionally, two date objects may now be subtracted to find the
- number of days between them.
-
- 4. I have consolidated the print functions into one function,
- formatDate, which accepts an enum value as its format type.
-
- MDY - returns a buffer with the date formatted as MM/DD/YYYY
- DAY - returns a buffer with the day of the week name only
- MONTH- returns a buffer with the month name only
- FULL - returns a buffer with the date formatted as DAY MMMMM DD, YYYY
- EUROPEAN- returns a buffer with the date formatted as DD MMMMMM, YYYY
-
- 5. The ostream << operator has been overloaded as a friend function
- to handle Date objects. In this implementation the format returned
- is fixed at MM/DD/YYYY, however an equivalent to the ios::setf
- function could be added to maintain a static member in the Date
- class to handle multiple formatting options. A companion << operator
- has been included to handle dos.h date structs, which are returned
- by the getDate() function.
-
- 6. Several utility functions have been provided:
-
- isLeapYear - returns 1 if a leap year, 0 if not
- dayOfYear - returns the day relative to Jan. 1
- eom - returns a dos.h "date" struct (format YYYYDDMM)
- with the last day of the month of the date object
- getDate - returns a dos.h "date" struct (format YYYYDDMM)
- equivalent to the date object
-
-
- IMPLEMENTATION NOTES.
-
- I have attempted to optimize the code for the Borland C++ compiler,
- including the specification of const where applicable, the passing
- of references where advisable, and the use of constructor initializers
- where needed. However I have not made an exhaustive analysis of this
- subject.
-
- Those of you who are using Eric's version will note that I have
- capatilized the class name to Date, to avoid conflict with Borland's
- "date" struct defined in DOS.H, which is also used by two functions.
- Please be wary of the potential for capitalization errors here.
- Also, I have altered the capitalization of several function names
- to conform with Borland's suggested convention.
-
- Also, I reorganized the source according to common distribution
- formats.
-
- Thus, this ZIP file contains:
-
- DATECLS3.HPP - the header file
- DATECLS3.CPP - the member functions
- DATEDEMO.CPP - a test program (and a messy one at that)
- DATECLS3.DOC - the file you're reading
-
-
- Future possibilities for enhancement include:
-
- 1. Maintenance of a static variable to handle global date format
- preferences (MDY, FULL, etc.) which would be used to control
- the overloaded << operator (now fixed at the MDY format). This
- would be more convenient than using the formatDate routine.
-
- 2. Maintenance of a static variable to handle other print format
- preferences. (Ideas would be to strip the century from the
- MDY format (i.e 10/15/91 instead of 10/15/1991), print
- abbreviated day or month names (i.e. MON, TUE, JAN, FEB), and
- the like). This would probably be a set of bit flags which would
- work (and be set) like the ios::setf options.
-
- 3. Adding a derived Time class, for those applications which require
- the ability to track more than just dates. This would allow the
- manipulation of times for all dates (not just since 1980), and
- arithmetic calculations as well.
-
- This is a truly pleasing example of co-operation among professionals, and
- an "object" study in the code reusability of OOP, resulting in three releases
- of one class within a single month by three different analysts who have never
- met. I thank Steve and Eric for their inspiration and generousity, and hereby
- contribute my additions to the public domain.
-
- I would welcome further comments, suggestions and enhancements as well.
- Good luck!
-
- Christopher Hill
- 72030,2606
-
-
- Documentation notes for Version 3.1
- ===================================
-
- Subsequent to release 3.00, we (Hill & Simon) decided to collaborate on
- several further releases of this date class. This, the first, contains two
- new features, as well as a few minor bug fixes.
-
- 1. There was a minor bug in the original Computer Language julian/gregorian
- date conversion routines having to do with negative years.
-
- 2. The isLeapYear function did not take into account that, prior to 1582,
- years ending in 00 were also leap years.
-
- 3. The two-dimensional array of the number of days in each month has been
- eliminated in favor of a computational approach.
-
- 4. We have implemented suggestions 1 & 2 from the wish list above. The
- function Date::setFormat(XXXX) maintains a static variable (one occurance
- for all Date objects, which controls the format which the << operator
- uses to print objects. "XXXX" can be MONTH, MDY, DAY, FULL, or EUROPEAN.
- The setting defaults to MDY, but once altered, remains altered until reset
- by another call to setFormat.
-
- The function Date::setOption(Option, Action) maintains a similar static
- variable which enables certain print formatting options. Available options
- at this point are:
-
- NO_CENTURY -- Suppress the printing of the century when
- in the MDY format (ex: 01/01/91 instead of
- 01/01/1991).
-
- DATE_ABBR -- Abbreviate month and day names when printing
- in the MONTH, DAY, FULL or EUROPEAN formats.
- (ex. MON, TUE, JAN, FEB, etc.) The length
- or the abbreviation is controlled by a
- DEFINED constant in DATECL31.HPP named
- ABBR_LENGTH, preset to 3.
-
- "Action" is either ON or OFF, and defaults to ON. (Example, the call
- Date::setOption(NO_CENTURY) turns on the century suppression option, and
- it remains set until the call Date::setOption(NO_CENTURY, OFF) is made.
-
-
- More features, including further expanded print formatting features,
- the derived Time class mentioned above, conversion into various calendar
- formats (Jewish, Chinese, Arabic, etc.), ability to increment Date objects
- by years and months instead of merely days, holiday computations, and more
- are planned. Stay tuned.
-
- Any questions, comments, or suggestions are welcomed. Please contact
- either of us.
-
-
- Christopher Hill Eric Simon
- 72030,2606 70540,1522
-
-
-